package com.stony.orc;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;

/**
 * <p>orcTest
 * <p>com.stony.orc
 *
 * @author stony
 * @version 下午6:38
 * @since 2017/11/16
 */
public class VisitRecord {
    long id;
    BigDecimal price;
    @JsonProperty("date_time")
    Timestamp dateTime;
    @JsonProperty("user_name")
    String userName;
    String doctor;
    @JsonProperty("hospital_number")
    long hospitalNumber;
    String tonic;
    @JsonProperty("tonic_number")
    long tonicNumber;
    int age;
    String sex;
    @JsonProperty("update_time")
    Timestamp updateTime;

    @JsonProperty("tonic_list")
    List<Tonic> tonicList;

    @JsonIgnore
    @JsonProperty("tonic_json")
    String tonicJson;

    String comment;

    public VisitRecord() {
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public Timestamp getDateTime() {
        return dateTime;
    }

    public void setDateTime(Timestamp dateTime) {
        this.dateTime = dateTime;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getDoctor() {
        return doctor;
    }

    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }

    public long getHospitalNumber() {
        return hospitalNumber;
    }

    public void setHospitalNumber(long hospitalNumber) {
        this.hospitalNumber = hospitalNumber;
    }

    public String getTonic() {
        return tonic;
    }

    public void setTonic(String tonic) {
        this.tonic = tonic;
    }

    public long getTonicNumber() {
        return tonicNumber;
    }

    public void setTonicNumber(long tonicNumber) {
        this.tonicNumber = tonicNumber;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }

    public List<Tonic> getTonicList() {
        if (tonicList == null || tonicList.isEmpty()) {
            if (tonicJson != null && tonicJson.length() > 1) {
                tonicList = JSON.parseArray(tonicJson, Tonic.class);
            }
            if (tonicList == null || tonicList.isEmpty()) {
                if (tonic != null && tonic.length() > 1) {
                    tonicList = JSON.parseArray(tonic, Tonic.class);
                }
            }
        }
        return tonicList;
    }

    public void setTonicList(List<Tonic> tonicList) {
        this.tonicList = tonicList;
    }

    public String getTonicJson() {
        if (tonicJson == null) {
            if (tonicList != null) {
                tonicJson = JSON.toJSONString(tonicList);
            }
        }
        return tonicJson;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }
}